<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" isELIgnored="false" %>


  <script type="text/javascript">

      $(function(){
          $("#ordersdatagrid").datagrid({
              url:'${pageContext.request.contextPath}/orders/findAll',
              pagination:true,
              method:'get',
              fit:true,
              pageSize:5,
              pageList:[5,10,15,20,25],
              fitColumns:true,
              striped:true,
              remoteSort:false,
              checkOnSelect:false,
              singleSelect:true,
              toolbar:'#usertoolbar',
              onLoadSuccess:function(){
                  $(".btn").linkbutton({
                      plain:true
                  })
              },
              columns:[[
                  {title:'用户id',field:'userid',align:'center',width:100},
                  {title:'手机号',field:'tel',align:'center',width:100},
                  {title:'收货人',field:'receiver',align:'center',width:100},
                  {title:'收货人地址',field:'address',align:'center',width:100},
                  {title:'商品名',field:'productname',align:'center',width:100},
                  {title:'商品图片',field:'path',align:'center',formatter:function(index,row,value){
                      return "<img src='${pageContext.request.contextPath}"+row.path+"' style='width:120px;height:160px'/>"
                      }},
                  {title:'价格',field:'price',align:'center',width:100},
                  {title:'押金',field:'deposit',align:'center',width:100},
                  {title:'运费',field:'freight',align:'center',width:100},
                  {title:'租期',field:'lease',align:'center',width:100},
                  {title:'状态',field:'status',align:'center',width:100},
                  {title:'操作',field:'options',width:300,formatter:function(index,row,value){
                      return "<a href='javascript:;' onclick='openUpdateOrders("+JSON.stringify(row)+")' class='btn' data-options=\"iconCls:'icon-edit',\">修改订单</a>"+
                          "<a href='javascript:;' onclick=\"deleteOrders('"+row.orderid+"')\" class='btn' data-options=\"iconCls:'icon-edit'\">删除订单</a>"

                      }}
              ]]
          })

      });

    //打开用户详细信息面板
    function openUpdateOrders(row){
        $("#openUpdateDialog").dialog({
            width:450,
            height:450,
            title:'员工详细信息',
            iconCls:'icon-man',
            href:'${pageContext.request.contextPath}/back/orders/updateOrders.jsp?orderid='+row.orderid+'&productorderid='+row.productorderid,
            buttons:[{
                text:'关闭',
                iconCls:'icon-remove',
                handler:function(){
                    $("#openUpdateDialog").dialog('close');
                }
            },{
                text:'更新',
                iconCls:'icon-save',
                handler:updateOrders
            }],

        })
    }

    function updateOrders(){
        $("#updateOrdersForm").form({
            url:'${pageContext.request.contextPath}/orders/update',
            onSubmit:function(){
                return $(this).form('validate');
            },
            success:function(result){
                $("#ordersdatagrid").datagrid('reload');
                $("#openUpdateDialog").dialog('close');
            }
        })
        $("#updateOrdersForm").form('submit');

    }

    //模糊查询
    function findByLike(value,name){
        $("#ordersdatagrid").datagrid({
            url:'${pageContext.request.contextPath}/back/user/user.json/?param1='+name+'&param2='+value
        })
    }

    function deleteOrders(orderid){
        $.messager.confirm('删除提醒','确定要删除吗？?',function(r){
            if(r){
                $.post("${pageContext.request.contextPath}/orders/delete",{"orderid":orderid},function(result){
                    $("#ordersdatagrid").datagrid('reload');
                    showMessage(result.message);
                })
            }
        })
    }
  </script>

<table id="ordersdatagrid" ></table>
<div id="usertoolbar">
 </a>
  <input class="easyui-searchbox" data-options="prompt:'请输入',menu:'#mm',width:180,searcher:findByLike" >
</div>
<div id="mm">

  <div data-options="iconCls:'icon-man',name:'name'">姓名</div>
  <div data-options="iconCls:'icon-man',name:'status'">状态</div>

</div>
<div id="openUpdateDialog"></div>

